<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="strutsTags"%>
<%@ taglib prefix="jscalendar" uri="/jscalendar"%>
<html>
	<head>
		<title>绩效报表</title>
		<script type="text/javascript">
		$(function() {
			$("#tabs").tabs();
		});
	</script>
		<style type="text/css">
#tabs-1,#tabs-2,#tabs-3,#tabs-4,#tabs-5{
	background-color: #ECF6FB;
	border-top: 1px #6BB5DA solid;
}
</style>
	</head>
	<body>
		<s:component template="bodyhead">
			<s:param name="pagetitle" value="'绩效报表：'" />
			<s:param name="helpUrl" value="'37'" />
		</s:component>
		<div id="tabs">
			<ul>
				<li>
					<a href="#tabs-1" onclick="clearShow();">员工绩效对比分析</a>
				</li>
				<li>
					<a href="#tabs-2" onclick="clearShow();">员工绩效历史分析</a>
				</li>
				<li>
					<a href="#tabs-3" onclick="clearShow();">部门绩效历史分析</a>
				</li>
				<li>
					<a href="#tabs-4" onclick="clearShow();">绩效等级结果分布</a>
				</li>
				<li>
					<a href="#tabs-5" onclick="clearShow();">绩效等级指标分布</a>
				</li>
			</ul>
			<div id="tabs-1">
					<p/>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
				<td align="right">考核周期:</td>
				<TD><s:select name="select01_pppId" list="perfplanperiodList" listKey="pppId" listValue="pppName" emptyOption="true"></s:select>
				</TD>
				<td align="right">考核方案:</td>
				<TD><s:select name="select01_psId" list="perfschemaList" listKey="psId" listValue="psName" emptyOption="true"></s:select>
				</TD>
				</tr>
				<tr>
			<td align="right">被考核员工:</td>
			<td>
				<s:hidden id="empIds" name="empIds"/>
				<s:textfield id="empName" size="30" readonly="true"/>
				<img onclick="selectEmp();" id="search_emp" alt='点击图标选择员工' title="点击图标选择员工" class="urlimg" src="../resource/images/search_icon.gif"/>
			</td>
			</tr>
			</table>
				</td>
				<td class="prompt_div_bottom">				
					<input class="button" type="button" value="查看"
						onclick="display('select01','HTML');">
					<input class="button" type="button" value="PDF下载"
						onclick="display('select01','PDF');">
				</td>
			</tr>
		</table>			
		</div>
			<div id="tabs-2">
					<p/>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
				<td align="right">考核方案:</td>
				<TD><s:select name="select02_psId" list="perfschemaList" listKey="psId" listValue="psName" emptyOption="true"></s:select>
				</TD>
				<td align="right">考核周期种类:</td>
				<td>
					<s:select  name="select02_periodType" list="perfplanperiodTypeList" emptyOption="false"></s:select>
				</td>
				
				<td align="right">被考核员工:</td>
				<td>
					<s:hidden id="oneEmp" name="oneEmp"/>
					<s:textfield id="oneEmpName" size="10" readonly="true"/>
					<img onclick="showChooseEmpDiv(4,1,'','oneEmpName','oneEmp');" alt="点击图标选择员工" title="点击图标选择员工" class="urlimg" src="../resource/images/search_icon.gif"/>
				</td>
						</tr>
						<tr>
						<td align="right">绩效开始日期:</td>
				<td>
				<s:textfield  id="startDate_select02" name="startDate" required="true" size="10" maxlength="10"/>
				<img onclick="WdatePicker({el:'startDate_select02'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">
				</td>
				<td align="right">绩效结束日期:</td>
				<td>
				<s:textfield  id="endDate_select02" name="endDate" required="true" size="10" maxlength="10" onchange="if (!isComdate(document.getElementById('startDate_select02').value, document.getElementById('endDate_select02').value)){alert('绩效开始日期必须小于绩效结束日期!');document.getElementById('endDate_select02').value=''}" />
				<img onclick="WdatePicker({el:'endDate_select02'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">
				</td>
						</tr>
				</table>
				</td>
				<td class="prompt_div_bottom">				
					<input class="button" type="button" value="查看"
						onclick="display('select02','HTML');">
					<input class="button" type="button" value="PDF下载"
						onclick="display('select02','PDF');">
				</td>
			</tr>
		</table>	
				</div>
	<div id="tabs-3">
					<p/>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
				<td align="right">考核方案:</td>
				<TD><s:select name="select03_psId" list="perfschemaList" listKey="psId" listValue="psName" emptyOption="true"></s:select>
				</TD>
				<td align="right">考核周期种类:</td>
				<td>
					<s:select  name="select03_periodType" list="perfplanperiodTypeList" emptyOption="false"></s:select>
				</td>
				<td align="right">部门:</td>
				<td>
			    <s:orgselector id="orgselector_select03"  name="departmentName" isShowPb="false" hiddenFieldName="departmentId" />
				</td>				</tr>
				<tr>
				<td align="right">绩效开始日期:</td>
				<td>
				<s:textfield  id="startDate_select03" name="startDate" required="true" size="10" maxlength="10"/>
				<img onclick="WdatePicker({el:'startDate_select03'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">
				</td>
				<td align="right">绩效结束日期:</td>
				<td>
				<s:textfield  id="endDate_select03" name="endDate" required="true" size="10" maxlength="10" onchange="if (!isComdate(document.getElementById('startDate_select03').value, document.getElementById('endDate_select03').value)){alert('绩效开始日期必须小于绩效结束日期!');document.getElementById('endDate_select03').value=''}" />
				<img onclick="WdatePicker({el:'endDate_select03'})" class="dateimg" src="../resource/js/My97DatePicker/skin/datePicker.gif">
				</td>
						</tr>
				</table>
				</td>
				<td class="prompt_div_bottom">				
					<input class="button" type="button" value="查看"
						onclick="display('select03','HTML');">
					<input class="button" type="button" value="PDF下载"
						onclick="display('select03','PDF');">
				</td>
			</tr>
		</table>	
				</div>
				
		<div id="tabs-4">
					<p/>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td align="right">考核周期:</td>
				<TD><s:select name="select04_pppId" list="perfplanperiodList" listKey="pppId" listValue="pppName" emptyOption="true"></s:select>
				</TD>
				<td align="right">考核方案:</td>
				<TD><s:select name="select04_psId" list="perfschemaList" listKey="psId" listValue="psName" emptyOption="true"></s:select>
				</TD>
			<td align="right">部门:</td>
				<td>
			    <s:orgselector id="orgselector_select04"  name="departmentName" isShowPb="false" hiddenFieldName="departmentId" />
				</td>	
				<td class="prompt_div_bottom">				
					<input class="button" type="button" value="查看"
						onclick="display('select04','HTML');">
					<input class="button" type="button" value="PDF下载"
						onclick="display('select04','PDF');">
				</td>
			</tr>
			<tr>
			<td colspan="20">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr align="center">
						A:(<s:textfield id="select04_a_low" name="perfDegree.a_low" cssStyle="width:30px;" value="90" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select04_a_height" name="perfDegree.a_height" cssStyle="width:30px;" value="100" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						B:(<s:textfield id="select04_b_low" name="perfDegree.b_low" cssStyle="width:30px;" value="80" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select04_b_height" name="perfDegree.b_height" cssStyle="width:30px;" value="90" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						C:(<s:textfield id="select04_c_low" name="perfDegree.c_low" cssStyle="width:30px;" value="70" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select04_c_height" name="perfDegree.c_height" cssStyle="width:30px;" value="80" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						D:(<s:textfield id="select04_d_low" name="perfDegree.d_low" cssStyle="width:30px;" value="60" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select04_d_height" name="perfDegree.d_height" cssStyle="width:30px;" value="70" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						E:(<s:textfield id="select04_e_low" name="perfDegree.e_low" cssStyle="width:30px;" value="0" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select04_e_height" name="perfDegree.e_height" cssStyle="width:30px;" value="60" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						</tr>
					</table>
			</td>
			</tr>
		</table>			
		</div>
							
		<div id="tabs-5">
					<p/>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td align="right">考核周期:</td>
				<TD><s:select id="select05_pppId" name="select05_pppId" list="perfplanperiodList" listKey="pppId" listValue="pppName" emptyOption="true"></s:select>
				</TD>
				<td align="right">考核方案:</td>
				<TD><s:select id="select05_psId" name="select05_psId" list="perfschemaList" listKey="psId" listValue="psName" emptyOption="true"></s:select>
				</TD>
			<td align="right">部门:</td>
				<td>
			    <s:orgselector id="orgselector_select05"  name="departmentName" isShowPb="false" hiddenFieldName="departmentId" />
				</td>	
				<td class="prompt_div_bottom">				
					<input class="button" type="button" value="查看"
						onclick="initTableList();">
				</td>
			</tr>
			<tr>
			<td colspan="20">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr align="center">
						A:(<s:textfield id="select05_a_low" cssStyle="width:30px;" value="90" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select05_a_height" cssStyle="width:30px;" value="100" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						B:(<s:textfield id="select05_b_low" cssStyle="width:30px;" value="80" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select05_b_height" cssStyle="width:30px;" value="90" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						C:(<s:textfield id="select05_c_low" cssStyle="width:30px;" value="70" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select05_c_height" cssStyle="width:30px;" value="80" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						D:(<s:textfield id="select05_d_low" cssStyle="width:30px;" value="60" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select05_d_height" cssStyle="width:30px;" value="70" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						E:(<s:textfield id="select05_e_low" cssStyle="width:30px;" value="0" onkeypress="MKeyIsNumber();" maxlength="3"/>-<s:textfield id="select05_e_height" cssStyle="width:30px;" value="60" onkeypress="MKeyIsNumber();" maxlength="3"/>)
						</tr>
					</table>
			</td>
			</tr>
		</table>			
		</div>	
</div>
		<p>
			&nbsp;
		</p>
				<IFRAME ID="reportArea" name="reportArea" marginWidth="0"
					marginHeight="0" frameborder="0" align="left" width="100%"
					height="480" src="" style="overflow-y: auto;">
				</IFRAME>
<div id="dlgSelectEmp" title="被考核员工" class="prompt_div_inline">
	<div id="mulSelect">
		<input type="hidden" id="empStatus" value="0"/>
		<s:empselector id="empselector" name="emp.empDeptNo.departmentName" condition="allEmp&empStatus" hiddenFieldName="emp.empDeptNo.id"/>
	</div>
	<div class="prompt_div_bottom" style="valign:middle">
	    <input class="button" type="button" id="empAdd" onclick="empAdd();" value="确定" />
	    <input class="button" type="button" onclick="hrm.common.closeDialog('dlgSelectEmp');" value="取消" />
	</div>
</div>
	<script type="text/javascript">
	hrm.common.initDialog('dlgSelectEmp',560);
	// 设定定时器
	var MyInterval;
				
	function selectEmp() {
		empSelector_searchEmp();
		$('#dlgSelectEmp').dialog('option','modal',false);
		hrm.common.openDialog('dlgSelectEmp');
	}
	
	function empAdd(){
		var selectedName = empSelector_choseEmpNameStr();
		var selectedId = empSelector_choseEmpIdStr();
		$("#empName").val(selectedName);
		$("#empIds").val(selectedId);
		hrm.common.closeDialog('dlgSelectEmp');
	}
	
	function checkPeriod(id){
	var my_period  = $('#'+id+'_pppId').val();
		if(my_period == null || my_period =='') {
			alert("请选择考核周期！");
			return false;
		}
		return true;
	}
	
	function checkPeriodType(id){
	var my_period_type  = $('#'+id+'_periodType').val();
		if(my_period_type == null || my_period_type =='') {
			alert("请选择考核周期种类！");
			return false;
		}
		return true;
	}
	
	function checkStartDate(id){
		var my_start_date  = $('#startDate_'+id).val();
		if(my_start_date == null || my_start_date =='') {
			alert("请选择开始日期！");
			return false;
		}
		return true;
	}
	
	function checkEndDate(id){
		var my_end_date  = $('#endDate_'+id).val();
		if(my_end_date == null || my_end_date =='') {
			alert("请选择结束日期！");
			return false;
		}
		return true;
	}
	
	function checkOneChoosedEmp(){
	var my_one_emp = $('#oneEmpName').val();
	if(my_one_emp == null || my_one_emp == ''){
		alert("请选择员工！");
		return false;
	}
	return true;
	}
	
	function checkSchema(id){
		var my_schema  = $('#'+id+'_psId').val();
		if(my_schema == null || my_schema =='') {
			alert("请选择考核方案！");
			return false;
		}
		return true;
	}
	
	function checkChoosedEmp(){
	var my_emp = $('#empName').val();
	if(my_emp == null || my_emp == ''){
		alert("请选择员工！");
		return false;
	}
	return true;
	}
	var e_low;
	var e_height;
	var d_low;
	var d_height;
	var c_low;
	var c_height;
	var b_low;
	var b_height;
	var a_low;
	var a_height;	
	function checkZone(id){
	   		e_low = $('#'+id+'_e_low').val();
		    e_height = $('#'+id+'_e_height').val();
			if((isEmpty(e_low) && !isEmpty(e_height)) || (!isEmpty(e_low) && isEmpty(e_height))){
				alert("等级值段区间E必须成对填写！");
				return false;
			}
			if(isEmpty(e_low) && isEmpty(e_low) && e_height<e_low){
				alert("等级值段区间E下限必须小于上限！");
				return false;
			}
		    d_low = $('#'+id+'_d_low').val();
		    d_height = $('#'+id+'_d_height').val();
			if((isEmpty(d_low) && !isEmpty(d_height)) || (!isEmpty(d_low) && isEmpty(d_height))){
				alert("等级值段区间D必须成对填写！");
				return false;
			}
			if(isEmpty(d_low) && isEmpty(d_low) && d_height<d_low){
				alert("等级值段区间D下限必须小于上限！");
				return false;
			}
			c_low = $('#'+id+'_c_low').val();
			c_height = $('#'+id+'_c_height').val();
			if((isEmpty(c_low) && !isEmpty(c_height)) || (!isEmpty(c_low) && isEmpty(c_height))){
				alert("等级值段区间C必须成对填写！");
				return false;
			}
			if(isEmpty(c_low) && isEmpty(c_low) && c_height<c_low){
				alert("等级值段区间C下限必须小于上限！");
				return false;
			}
			b_low = $('#'+id+'_b_low').val();
		    b_height = $('#'+id+'_b_height').val();
			if((isEmpty(b_low) && !isEmpty(b_height)) || (!isEmpty(b_low) && isEmpty(b_height))){
				alert("等级值段区间B必须成对填写！");
				return false;
			}
			if(isEmpty(b_low) && isEmpty(b_low) && b_height<b_low){
				alert("等级值段区间B下限必须小于上限！");
				return false;
			}
		    a_low = $('#'+id+'_a_low').val();
		    a_height = $('#'+id+'_a_height').val();
			if((isEmpty(a_low) && !isEmpty(a_height)) || (!isEmpty(a_low) && isEmpty(a_height))){
				alert("等级值段区间A必须成对填写！");
				return false;
			}
			if(isEmpty(a_low) && isEmpty(a_low) && a_height<a_low){
				alert("等级值段区间A下限必须小于上限！");
				return false;
			}
			
			return true;
	
	}
	
	function viewReport(reportFileLocation,format,id){
		var baseReportURL = "../report/performanceReport.action";
        var baseEmployeeReportFolador = "/report/performance/";
        var resultURL = baseReportURL +"?reportFormat="+format+"&reportFileLocation="+baseEmployeeReportFolador+reportFileLocation;
		MyInterval=window.setInterval("hideDia()",500);
		$('#divWait').show();
       resultURL+="&empIds="+$('#empIds').val();
       resultURL+="&psId="+$('#'+id+'_psId').val();
       if(id == 'select01' || id == 'select04' )resultURL+="&pppId="+$('#'+id+'_pppId').val();
       if(id == 'select02') resultURL += "&oneEmp="+$('#oneEmp').val();
       if(id == 'select02' || id == 'select03' || id == 'select04')  {
            resultURL+="&newStartDate="+$('#startDate_'+id).val();
       		resultURL+="&newEndDate="+$('#endDate_'+id).val();
       		resultURL += "&periodType="+$('#'+id+'_periodType').val();
       		resultURL+="&departmentId="+$('#orgselector_returnString_orgselector_select03').val();
       	}
       	if(id == 'select04' ){
   			if(!checkZone(id))return;
			resultURL += "&perfDegree.e_low="+e_low+"&perfDegree.e_height="+e_height+"&perfDegree.d_low="+d_low+"&perfDegree.d_height="+d_height+"&perfDegree.c_low="+c_low+"&perfDegree.c_height="+c_height+
					"&perfDegree.b_low="+b_low+"&perfDegree.b_height="+b_height+"&perfDegree.a_low="+a_low+"&perfDegree.a_height="+a_height;
       	}
       $("#reportArea").attr("src",resultURL);
    }
    function display(id,format){
        if(id == 'select01'){
        	if(!checkPeriod(id) || !checkSchema(id) || !checkChoosedEmp())return ;
        	reportFileLocation = 'performance_employee_compare.rptdesign';
        }
        else if(id == 'select02'){
       		 if(!checkSchema(id) || !checkPeriodType(id) || !checkStartDate(id) || !checkEndDate(id) ||!checkOneChoosedEmp())return ;
        	reportFileLocation = 'dept_perf_history.rptdesign';
        }
        else if(id == 'select03'){
        	if(!checkSchema(id) || !checkPeriodType(id) || !checkStartDate(id) || !checkEndDate(id))return ;
        	reportFileLocation = 'department_history.rptdesign';
        }
        else if(id == 'select04'){
       		 if(!checkPeriod(id) || !checkSchema(id) ) return ;
        	reportFileLocation = 'performance_degree_result.rptdesign';
        }
        else return ;
        viewReport(reportFileLocation,format,id);
    }
    
    function hideDia(){
    	if($('#reportArea').contents().find('img')[0] != null || $('#reportArea').contents().find('div:last').text() != ""){
    		window.clearInterval(MyInterval);
    		$('#divWait').hide();
    	}
   	}
     
	//清楚页面中reportArea的内容。
	function clearShow(){
	 	 $("#reportArea").attr("src",'');
	}
</script>
<jsp:include page="../../sitemesh/div_wait.jsp" flush="true"></jsp:include>
<%@ include file="../../profile/search_emp_div.jsp"%>
<jsp:include page="perfReportTable.jsp" flush="true"></jsp:include>
</body>
</html>
